package com.encryption.controls.loading
{
	import flash.display.DisplayObject;
	
	import mx.managers.PopUpManager;

	public class LoadingPopUpManager
	{
		private static const loading:Loading = new Loading();
		public function LoadingPopUpManager()
		{
		}
		
		public static function centerPopUp(parent:DisplayObject,text:String="加载中...",page:Loading=null):Loading
		{
			if(page == null)
				page = loading;
			
			if(!page.isPopUp){
				page.width = parent.width;
				page.height = parent.height;
				page.text = text;
				PopUpManager.addPopUp(page,parent);
				PopUpManager.centerPopUp(page);
			}
			
			return page;
		}
		
		public static function removePopUp(page:Loading=null):void{
			if(page == null)
				page = loading;
			
			if(page.isPopUp)
				PopUpManager.removePopUp(page);
		}
	}
}